import { VabRouteRecord } from '~/types/router'
import { defHttp } from '/@/utils/request'

export interface Menu extends Omit<defs.common.Menu, 'meta'> {
  meta: Partial<defs.common.RouteMeta>
  level: number
  children?: Omit<Menu, 'children'>[]
}
export const addMenuApi = (data: Partial<Menu>) => {
  return defHttp.post<Menu>({ url: '/api/menu', data })
}

export const getMenuListApi = () => {
  return defHttp.get<Menu[]>({ url: '/api/menu' })
}

export const updateMenuApi = (id: number, data: Partial<Menu>) => {
  return defHttp.put<number[]>({ url: `/api/menu/${id}`, data })
}

export const deleteMenuApi = (id: string) => {
  return defHttp.delete<number>({ url: `/api/menu/${id}` })
}
